﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bus.Bll;
using Bus.Model;

public partial class admin_custom_cusmanage : System.Web.UI.Page
{
    private tb_custom cusBll = new tb_custom();
    private LogModel  lm = null;
    protected tb_log logbll = new tb_log();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.ProviderPageData();
        }

    }
    private void ProviderPageData()
    {
        AspNetPager1.PageSize = 50;
        AspNetPager1.RecordCount = cusBll.GetRecordCount("");
        cusrep.DataSource = cusBll.GetListByPage("", "cid desc", (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex *AspNetPager1.PageSize);
        cusrep.DataBind();
    }
    public string ToSex(object str)
    {
        if (str.ToString() == "0")
            return "男";
        else
            return "女";
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        ProviderPageData();
    }
    protected void LinkButton1_click(object sender, EventArgs e)
    {
        LinkButton lbt = sender as LinkButton;
        int cid = int.Parse(lbt.CommandArgument);
        if (cusBll.Delete(cid))
        {
            lm = new LogModel();
            lm.userid = int.Parse(Session["userid"].ToString());
            lm.op = "删除";
            lm.memo = "删除一个乘客";
            lm.opdate = DateTime.Now;
            logbll.Add(lm);
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除成功！');</script>");
            ProviderPageData();
        }
        else
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除失败！');</script>");
    }
}
